var nodemailer = require("nodemailer");

// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport({
 host: "mail.stardibs.com", // hostname
 port: 26, // port for secure SMTP
    auth: {
        user: "support@stardibs.com",
        pass: "$t@rd!bs0217"
    }
});

// setup e-mail data with unicode symbols
module.exports.sendEmail = function(recipient){
	
	console.log("SENDING EMAIL!!!!!!!!!!!!!!!!!!!!!!!!!!! START 101");
	var mailOptions = {
		    from: "Fred Foo  <foo@blurdybloop.com>", // sender address
		    to: recipient, // list of receivers
		    subject: "Hello ", // Subject line
		    text: "Hello world ", // plaintext body
		    html: "<b>Hello world </b>" // html body
		}
	// send mail with defined transport object
	smtpTransport.sendMail(mailOptions, function(error, response){
	    if(error){
	        console.log(error);
	    }else{
	        console.log("Message sent: " + response.message);
	    }
	
	    // if you don't want to use this transport object anymore, uncomment following line
	    //smtpTransport.close(); // shut down the connection pool, no more messages
	});
	

	console.log("SENDING EMAIL!!!!!!!!!!!!!!!!!!!!!!!!!!! END");
}